package com.zqh.app.manager.impl;

import com.zqh.app.dao.MessageMapper;
import com.zqh.app.entity.Customer;
import com.zqh.app.entity.Message;
import com.zqh.app.manager.AppMessageManager;
import com.zqh.common.entity.Page;
import com.zqh.common.entity.Query;
import com.zqh.common.entity.R;
import com.zqh.common.utils.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("appMessageManager")
public class AppMessageManagerImpl implements AppMessageManager {
    @Autowired
    MessageMapper messageMapper;
    @Override
    public List<Message> listMessage(Page<Message> page, Query search) {
        return messageMapper.listForPage(page,search);
    }

    @Override
    public List<Message> listMessage1(Page<Message> page, Query search) {
        return messageMapper.listForPage1(page,search);
    }

    @Override
    public R sendMessage(Query form) {
        int count =  messageMapper.save(form);
        return CommonUtils.msg(count);
    }

    @Override
    public R getRongToken(Integer userId) {
        String  token  =  messageMapper.getRongToken(userId);
        return CommonUtils.msg(token);
    }

    @Override
    public List<Customer> listMessage2() {
        return messageMapper.listForPage2();
    }

    @Override
    public R saveys(Query form) {
        int count =  messageMapper.saveys(form);
        return  CommonUtils.msg(count);
    }

    @Override
    public R delCustomer(int customerServiceId) {
        int count =  messageMapper.remove(customerServiceId);
        return  CommonUtils.msg(count);
    }
}
